package com.niodata.dp.monitor.sharelib.entity.task;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.niodata.dp.util.TimeUtil;
import java.util.Date;

/**
 * Created by jixin on 18-2-5.
 */
public class TaskExecution {

  private String taskId;
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  private Date startTime;
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  private Date endTime;
  private int execId;
  private String status;
  private boolean success;
  private String taskName;
  private String flowName;
  private Long ownerId;
  private String ownerType;
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  private Date createTime;
  private int executorId;

  public Date getCreateTime() {
    return createTime;
  }

  public void setCreateTime(Date createTime) {
    this.createTime = createTime;
  }

  public Long getOwnerId() {
    return ownerId;
  }

  public void setOwnerId(Long ownerId) {
    this.ownerId = ownerId;
  }

  public String getOwnerType() {
    return ownerType;
  }

  public void setOwnerType(String ownerType) {
    this.ownerType = ownerType;
  }

  public String getTaskId() {
    return taskId;
  }

  public void setTaskId(String taskId) {
    this.taskId = taskId;
  }

  public Date getStartTime() {
    return startTime;
  }

  public void setStartTime(Date startTime) {
    this.startTime = startTime;
  }

  public Date getEndTime() {
    return endTime;
  }

  public void setEndTime(Date endTime) {
    this.endTime = endTime;
  }

  public int getExecId() {
    return execId;
  }

  public void setExecId(int execId) {
    this.execId = execId;
  }

  public boolean isSuccess() {
    return success;
  }

  public void setSuccess(boolean success) {
    this.success = success;
  }

  public String getStatus() {
    return status;
  }

  public void setStatus(String status) {
    this.status = status;
  }

  public String getTaskName() {
    return taskName;
  }

  public void setTaskName(String taskName) {
    this.taskName = taskName;
  }

  public String getFlowName() {
    return flowName;
  }

  public void setFlowName(String flowName) {
    this.flowName = flowName;
  }

  public int getExecutorId() {
    return executorId;
  }

  public void setExecutorId(int executorId) {
    this.executorId = executorId;
  }

  public String getDuration() {
    if (startTime != null && endTime != null && endTime.compareTo(startTime) > 0) {
      return TimeUtil.toReadableDuration(startTime, endTime);
    }
    return "";
  }
}
